<template>
	<view class="list-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="请假记录"></uni-navbar></view>

		<view class="info-box" v-if="id">
			<view class="info-title">
				{{ name }}
				<text class="dept">{{ dept }}</text>
			</view>
		</view>

		<view class="container">
			<view class="sign-box">
				<view class="pro-row" v-for="(item, index) in leaveList" :key="item.id">
					<view class="pro-title">{{ item.userName }}</view>
					<view class="pro-block flex">
						<view class="pro-left">小组名称:</view>
						<view class="pro-right">{{ item.userDept || '' }}</view>
					</view>
					<view class="pro-block flex">
						<view class="pro-left">请假时间:</view>
						<view class="pro-right">{{ item.createTime }}</view>
					</view>
					<view class="pro-block flex">
						<view class="pro-left">请假理由:</view>
						<view class="pro-right">{{ item.reasion }}</view>
					</view>
					<block v-if="item.nodeStatus == '已审批'">
						<view class="pro-block flex">
							<view class="pro-left">审批结果:</view>
							<view class="pro-right">{{ item.approveResult }}</view>
						</view>
						<view class="pro-block flex">
							<view class="pro-left">审批意见:</view>
							<view class="pro-right">{{ item.approveInfo }}</view>
						</view>
					</block>
					<block v-else>
						<view class="pro-block flex">
							<view class="pro-left">审批状态:</view>
							<view class="pro-right">{{ item.nodeStatus }}</view>
						</view>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			id: '',
			leaveList: '',
			dept: '',
			name: ''
		};
	},
	onLoad(option) {
		this.loadLogin();
		this.id = option.id;
		this.name = decodeURI(option.name);
		this.dept = decodeURI(option.dept);
		this.loadData();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.Authorization) {
				this.clientCode = this.userInfo.sysUser.clientCode;
				this.userId = this.userInfo.sysUser.id;
			} else {
				this.$logout();
			}
		},
		loadData() {
			let data = {
				pageNum: 1,
				pageSize: 9999,
				meetingId: this.id,
				userId: this.userId,
				clientCode: this.clientCode
			};
			this.$request('/huiyihuodong/hyhd-leave-records/queryMyRecordList?pageNum=1&pageSize=9999&meetingId=' + this.id + '&userId=' + this.userId, {}).then((res) => {
				this.leaveList = res.data.records;
			});
		}
	}
};
</script>

<style lang="scss">
.info-box {
	padding: 30rpx 30rpx;

	.info-title {
		margin-bottom: 14rpx;
	}
}
.pro-title {
	margin-bottom: 4px;
}
.sign-box {
	margin-top: 30rpx;
}
</style>
